<?php
namespace Home\Controller;
use Think\Controller;
class JbController extends BaseController {
    public function nowjb(){
        $map['id']=session('user.id');
      $status=M('user')->where($map)->getField('status'); 

     $jb= M('jbset')->find();
     $index='jb'.$status;
     $jb=$jb[$index];
        $this->assign("jb",$jb);
        $this->display();
    }

    public function sj_con(){
        $map['id']=session('user.id');

      $user=M('user')->where($map)->find(); 
      $jb=M('jbset')->find(); 
      $index='jb'.$user['status'];
      //$jb=$jb[$index];
      //var_dump($jb);exit();
      //$this->assign("jb",$jb);
     
      switch ($user['status']) {
          case '1':
          /* $con='邀请'.$jb['sj_jb2_jb1s'].'个及以上'.$jb['jb1'].','.$jb['sj_jb2_mons'].'个月累计'.($jb['sj_jb2_orders']*$jb['sj_jb2_mons']).' 或者 邀请'.$jb['sj_jb2_jb1s'].'个及以上'.$jb['jb1'].',连续'.$jb['sj_jb2_mons'].'个月每月'.$jb['sj_jb2_orders'].'单及以上';*/
        $con='邀请'.$jb['sj_jb2_jb1s'].'个及以上'.$jb['jb1'].','.$jb['sj_jb2_mons'].'个月累计'.($jb['sj_jb2_orders']*$jb['sj_jb2_mons']);
           $search['invite_id']=$map['id'];
           $search['status']=1;
           $months=$jb['sj_jb2_mons']-1;
           $this->assign('jb',$jb['jb1']);
              break;
        case '2':
/*            $con='邀请'.$jb['sj_jb3_jb2s'].'个及以上'.$jb['jb2'].','.$jb['sj_jb3_mons'].'个月累计'.($jb['sj_jb3_orders']*$jb['sj_jb3_mons']).' 或者 邀请'.$jb['sj_jb3_jb2s'].'个及以上'.$jb['jb2'].',连续'.$jb['sj_jb3_mons'].'个月每月'.$jb['sj_jb3_orders'].'单及以上';*/
       $con='邀请'.$jb['sj_jb3_jb2s'].'个及以上'.$jb['jb2'].','.$jb['sj_jb3_mons'].'个月累计'.($jb['sj_jb3_orders']*$jb['sj_jb3_mons']);
              $search['invite_id']=$map['id'];
           $search['status']=2;
             $months=$jb['sj_jb3_mons']-1;
            $this->assign('jb',$jb['jb2']);
              break;
        case '3':
          /*  $con='邀请'.$jb['sj_jb4_jb3s'].'个及以上'.$jb['jb3'].','.$jb['sj_jb4_mons'].'个月累计'.($jb['sj_jb4_orders']*$jb['sj_jb4_mons']).' 或者 邀请'.$jb['sj_jb4_jb3s'].'个及以上'.$jb['jb3'].',连续'.$jb['sj_jb4_mons'].'个月每月'.$jb['sj_jb4_orders'].'单及以上';*/

      $con='邀请'.$jb['sj_jb4_jb3s'].'个及以上'.$jb['jb3'].','.$jb['sj_jb4_mons'].'个月累计'.($jb['sj_jb4_orders']*$jb['sj_jb4_mons']);
              $search['invite_id']=$map['id'];
           $search['status']=3;
             $months=$jb['sj_jb4_mons']-1;
            $this->assign('jb',$jb['jb3']);
              break;
        case '4':
            $search['invite_id']=$map['id'];

            $con='您的身份已经是分公司，无法继续升级';
              break;
          
          default:
              # code...
              break;
      }
       $cur_count= M('user')->where($search)->count();
       $cur_num=D('order')->get_group_num($map['id'],$months);
         $begin=mktime(0,0,0,date('m')-$months,1,date('Y'));
        $this->assign("sj_con",$con);
        $this->assign("status",$user['status']);
        $this->assign("begin",$begin);
        $this->assign("cur_count",$cur_count);
        $this->assign("cur_num",$cur_num);
        $this->display();
    }


}
